<html>
<head><meta charset="utf-8"><title>error result alias · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html">error result alias</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231548078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231548078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> devsnek <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231548078">(Mar 23 2021 at 21:38)</a>:</h4>
<p>can we add an alias for <code>Result&lt;T, Box&lt;dyn std::error::Error&gt;&gt;</code> to std</p>



<a name="231549732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231549732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231549732">(Mar 23 2021 at 21:52)</a>:</h4>
<p>you want <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a></p>



<a name="231549759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231549759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231549759">(Mar 23 2021 at 21:52)</a>:</h4>
<p><code>std::error::Result</code> seems ok, but also kind of confusing</p>



<a name="231549790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231549790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231549790">(Mar 23 2021 at 21:52)</a>:</h4>
<p>it's not clear just from the name why it would be different from <code>std::result::Result</code></p>



<a name="231552491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231552491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Mazakas <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231552491">(Mar 23 2021 at 22:15)</a>:</h4>
<p>One thing to keep in mind with this polymorphic approach is that you lose Send + Sync info on the <code>Error</code> </p>
<p>One issue is that this alias only models one form of lifetime: uniquely owned</p>
<p>It does not include shared (<code>Arc&lt;dyn Error&gt;</code>) or non-owning (<code>&amp;'a dyn Error</code>)</p>



<a name="231554284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231554284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231554284">(Mar 23 2021 at 22:31)</a>:</h4>
<p>when would you want to return a borrowed <code>dyn Error</code>?</p>



<a name="231555599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231555599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Mazakas <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231555599">(Mar 23 2021 at 22:45)</a>:</h4>
<p>Hmm, good point.</p>
<p>I suppose maybe one of the few places might be <code>&amp;'static</code>.</p>
<p>Otherwise, you are correct, the use-case for borrowing does not seem strong</p>



<a name="231563608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231563608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231563608">(Mar 24 2021 at 00:14)</a>:</h4>
<p><span class="user-mention silent" data-user-id="219805">devsnek</span> <a href="#narrow/stream/122651-general/topic/error.20result.20alias/near/231548078">said</a>:</p>
<blockquote>
<p>can we add an alias for <code>Result&lt;T, Box&lt;dyn std::error::Error&gt;&gt;</code> to std</p>
</blockquote>
<p>we're trying to move away from <code>Box&lt;dyn Error&gt;</code> because it doesn't implement the <code>Error</code> trait so I'd be against adding this alias</p>



<a name="231563675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/231563675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#231563675">(Mar 24 2021 at 00:15)</a>:</h4>
<p>"we" being the error handling wg</p>



<a name="232570364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/error%20result%20alias/near/232570364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/error.20result.20alias.html#232570364">(Mar 31 2021 at 10:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="399737">Christian Mazakas</span> <a href="#narrow/stream/122651-general/topic/error.20result.20alias/near/231555599">said</a>:</p>
<blockquote>
<p>I suppose maybe one of the few places might be <code>&amp;'static</code>.</p>
<p>Otherwise, you are correct, the use-case for borrowing does not seem strong</p>
</blockquote>
<p><code>&amp;dyn Error + 'static</code> is for borrowed abstract errors</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>